define(['app'], function(app) {
	'use strict';

	var controller = function controller($scope, Promotionaddup_add_agent,$ionicSlideBoxDelegate,$stateParams) {
		$scope.act_id = $stateParams.id;
		$scope.prom_nums ={};
		//滑动切换
		$scope.selectTab = 0;
		$scope.activeSlide = function(index) {
			$scope.selectTab = index;
			$ionicSlideBoxDelegate.$getByHandle('tab-handle').slide(index);
		};
	    //滑动切换
		$scope.slideChanged = function(index) {
			$scope.selectTab = index;
		};
		$scope.init_data = function(){
			Promotionaddup_add_agent.promotion_statistics('$scope.act_id',function(data){
				$scope.datas = data;
                console.log($scope.datas);
//              var array = data.attention_num;
//				for(var o in array){  
//					if(array[o].region_id){
//						$scope.prom_nums[array[o].region_id] = new Object();
//						$scope.prom_nums[array[o].region_id]['region_id'] = array[o].region_id;
//						$scope.prom_nums[array[o].region_id]['attention_num'] = array[o].number;
//						$scope.prom_nums[array[o].region_id]['region_name'] = array[o].region_name;
//					}
//			    }  
//				array = data.jion_num;
//				for(var o in array){  
//					if(array[o].region_id && $scope.prom_nums[array[o].region_id]){
//						$scope.prom_nums[array[o].region_id]['jion_num'] = array[o].number;
//					}
//			    }  
//				array = data.money;
//				for(var o in array){  
//					if(array[o].region_id && $scope.prom_nums[array[o].region_id]){
//						$scope.prom_nums[array[o].region_id]['money'] = array[o].money;
//					}
//			    }  
//				array = data.count;
//				for(var o in array){  
//					if(array[o].region_id && $scope.prom_nums[array[o].region_id]){
//						$scope.prom_nums[array[o].region_id]['count'] = array[o].count;
//					}
//			    }  

//              $scope.datas.array = $scope.prom_nums;
//              console.log($scope.prom_nums);
//				console.log($scope.datas.array[001].region_id);
			})
		}
		$scope.init_data();
	}

	controller.$inject = ['$scope', 'Promotionaddup_add_agent','$ionicSlideBoxDelegate','$stateParams'];
	
	return app.registerController("promotionaddup_add_agentctrl",controller);
});


